
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>8.4 混合渲染开发实践：以 fluttertpc_scan 三方库为例 · Flutter for Harmony教程</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="坚果派">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-mind-maps/mindmaps.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-ace/ace.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-lou/lou.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="8.1如何使用Flutter与鸿蒙通信 FlutterChannel.html" />
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"repo":"ITmxs/gitbook","types":["star","watch","fork"],"size":"small"};
    </script>

    </head>
    <body>
         
<div class="donate-modal modal">
  <div class="modal-header">
    <div>
      <span>
        <img
          id="modal-avatar"
          class="modal-avatar"
          src="http://xkapp-uat.oss-cn-hangzhou.aliyuncs.com/2e7a3f70-80ab-4b50-93ec-a04dfeef949b/avatar-100.png"
        />
      </span>
      <span id="nickname"> breeze </span>
      <p class="modal-close close" onclick="closeDonateModal()">×</p>
    </div>
    <div class="message">
      <div class="tip">
        <i></i>
        <span>随意打赏，但不要超过一顿早餐钱 💕</span>
      </div>
    </div>
  </div>
  <div class="modal-content">
    <div class="modal-pay-way">
      <div id="wxpay" onclick="showDonateImg(0)">
        <input
          type="radio"
          name="pay-way"
          value="wxpay"
          class="zs-type"
          checked="checked"
        />
        <span>
          <img
            id="wxpay-logo"
            src=""
          />
        </span>
      </div>
      <div id="alipay" onclick="showDonateImg(1)">
        <input type="radio" name="pay-way" value="alipay" class="zs-type" />
        <span>
          <img
            id="alipay-logo"
            src=""
          />
        </span>
      </div>
    </div>
    <div class="modal-pay-qrcode">
      <img id="wxpay-code" src="https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202901895.png" />
      <img
        id="alipay-code"
        src="https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202843746.png"
        hidden
      />
    </div>
  </div>
</div>
<div class="mask"></div>


<div class="book">
  <div class="header-inner">
    <!-- LOGO -->
    <div class="logo"></div>
    <span class="title"></span>

    <!-- Search -->
    
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>


    <!-- Nav -->
    <ul class="header-nav">
      <li>
        <a href="https://www.gitbook.com/" target="_blank">坚果派官网</a>
      </li><li>
        <a href="https://www.npmjs.com/package/package" target="_blank">ArkUI实战</a>
      </li><li>
        <a href="https://space.bilibili.com/480883651" target="_blank">元服务开发实践</a>
      </li><li>
        <a href="https://blog.51cto.com/jianguo" target="_blank">OpenHarmony应用开发</a>
      </li>
    </ul>
  </div>

  <div class="book-summary">
    <div class="book-summary-title">文档目录</div>
     
    <nav role="navigation">


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    1.前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../坚果派介绍.html">
            
                <a href="../坚果派介绍.html">
            
                    
                    2.坚果派介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    3.Flutter与Dart介绍
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../chapter3/3.1Flutter介绍.html">
            
                <a href="../chapter3/3.1Flutter介绍.html">
            
                    
                    3.1Flutter介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../chapter3/3.2Dart介绍.html">
            
                <a href="../chapter3/3.2Dart介绍.html">
            
                    
                    3.2Dart介绍
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    4.HarmonyOS/OpenHarmony与ArkTS介绍
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../chapter4/4.1HarmonyOS">
            
                <span>
            
                    
                    4.1HarmonyOS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../chapter4/4.2OpenHarmony.html">
            
                <a href="../chapter4/4.2OpenHarmony.html">
            
                    
                    4.2OpenHarmony
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../chapter4/4.3HarmonyOSNEXT.html">
            
                <a href="../chapter4/4.3HarmonyOSNEXT.html">
            
                    
                    4.3HarmonyOS NEXT
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../chapter4/4.4ArkTS语言 .html">
            
                <a href="../chapter4/4.4ArkTS语言 .html">
            
                    
                    4.4ArkTS语言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../chapter4/4.5三者的差异 .md">
            
                <span>
            
                    
                    4.5三者的区别与联系
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    5.Flutter鸿蒙化
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" >
            
                <span>
            
                    
                    [5.1背景]
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" >
            
                <span>
            
                    
                    [5.2原理]
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../chapter2/2.3Impeller渲染引擎.html">
            
                <a href="../chapter2/2.3Impeller渲染引擎.html">
            
                    
                    5.3Impeller渲染引擎
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    6.鸿蒙Flutter开发环境配置（windows与mac）
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../chapter5/5.1windows环境配置.html">
            
                <a href="../chapter5/5.1windows环境配置.html">
            
                    
                    6.1windows环境配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../chapter5/5.2mac环境配置.html">
            
                <a href="../chapter5/5.2mac环境配置.html">
            
                    
                    6.2 mac环境配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../chapter5/5.6使用最新的fluttersdk配置开发环境.html">
            
                <a href="../chapter5/5.6使用最新的fluttersdk配置开发环境.html">
            
                    
                    6.3 使用 FlutterSDK 3.22.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../chapter5/5.4第一个鸿蒙Flutter应用程序.html">
            
                <a href="../chapter5/5.4第一个鸿蒙Flutter应用程序.html">
            
                    
                    6.4第一个鸿蒙Flutter应用程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../chapter5/5.5鸿蒙Flutter运行到HarmonyOS.md">
            
                <span>
            
                    
                    6.5运行到多平台
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../chapter5/5.7OpenHarmony设备运行指导.html">
            
                <a href="../chapter5/5.7OpenHarmony设备运行指导.html">
            
                    
                    6.6OpenHarmony设备运行指导
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../chapter5/5.8现有项目支持鸿蒙.html">
            
                <a href="../chapter5/5.8现有项目支持鸿蒙.html">
            
                    
                    6.7现有Flutter项目支持鸿蒙
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../chapter5/5.9鸿蒙版Flutter仓库变更.html">
            
                <a href="../chapter5/5.9鸿蒙版Flutter仓库变更.html">
            
                    
                    6.8鸿蒙版Flutter仓库变更
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../chapter5/5.11使用fvm.html">
            
                <a href="../chapter5/5.11使用fvm.html">
            
                    
                    6.9使用FVM管理
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    7.在鸿蒙应用中添加Flutter页面
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" >
            
                <span>
            
                    
                    7.1如何使用 FlutterPage
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" >
            
                <span>
            
                    
                    7.2如何使用混合开发添加跳转 FlutterEntry
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" >
            
                <span>
            
                    
                    7.3 harmonyos添加flutter页面跳转时路由的处理
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" >
            
                <span>
            
                    
                    8.在鸿蒙应用中使用Flutter Channel能力
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="8.1如何使用Flutter与鸿蒙通信 FlutterChannel.html">
            
                <a href="8.1如何使用Flutter与鸿蒙通信 FlutterChannel.html">
            
                    
                    8.1如何使用Flutter与鸿蒙通信 FlutterChannel
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.8.2" data-path="8.4 混合渲染开发实践：以 fluttertpc_scan 三方库为例.html">
            
                <a href="8.4 混合渲染开发实践：以 fluttertpc_scan 三方库为例.html">
            
                    
                    8.4 混合渲染开发实践：以 fluttertpc_scan 三方库为例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" >
            
                <span>
            
                    
                    9.与原生混合渲染
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" >
            
                <a target="_blank" href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/Flutter OHOS外接纹理适配简介.md">
            
                    
                    9.1Flutter OHOS外接纹理适配简介.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" >
            
                <a target="_blank" href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/如何使用多引擎 FlutterEngineGroup.md">
            
                    
                    9.2如何使用多引擎 FlutterEngineGroup
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" >
            
                <a target="_blank" href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/如何使用PlatformView.md">
            
                    
                    9.3如何使用PlatformView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" >
            
                <a target="_blank" href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/PlatformView同层渲染方案适配切换指导.md">
            
                    
                    9.4PlatformView同层渲染方案适配切换指导
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" >
            
                <span>
            
                    
                    9.5如何使用混合开发 module
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" >
            
                <span>
            
                    
                    10.开发Flutter静态库
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" >
            
                <a target="_blank" href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/如何使用混合开发 module.md">
            
                    
                    10.1开发module
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" >
            
                <a target="_blank" href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/开发package.md">
            
                    
                    10.2开发package
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" >
            
                <a target="_blank" href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/开发plugin.md">
            
                    
                    10.3开发plugin
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" >
            
                <a target="_blank" href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/开发FFI plugin.md">
            
                    
                    10.4开发FFI plugin
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" >
            
                <span>
            
                    
                    11.Packages使用指南
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../chapter11/11.1高效使用 Packages指南.html">
            
                <a href="../chapter11/11.1高效使用 Packages指南.html">
            
                    
                    11.1高效使用 Packages指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" >
            
                <span>
            
                    
                    11.2发布Packages
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" >
            
                <span>
            
                    
                    12.鸿蒙适配Flutter三方库
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../chapter12/12.1纯dart库无需迁移.html">
            
                <a href="../chapter12/12.1纯dart库无需迁移.html">
            
                    
                    12.1纯dart库无需迁移
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../chapter12/12.2坚果派已适配的库">
            
                <span>
            
                    
                    12.2坚果派目前适配三方库进展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../chapter12/12.3适配三方库之FlutterToast.html">
            
                <a href="../chapter12/12.3适配三方库之FlutterToast.html">
            
                    
                    12.3适配三方库之FlutterToast
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="../chapter12/12.4适配适配三方库之udid.md">
            
                <span>
            
                    
                    12.4适配三方库之udid
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" data-path="../chapter12/12.5适配torch_light.html">
            
                <a href="../chapter12/12.5适配torch_light.html">
            
                    
                    12.5适配torch_light.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="../chapter12/12.6适配flutter_native_contact_picker.html">
            
                <a href="../chapter12/12.6适配flutter_native_contact_picker.html">
            
                    
                    12.6适配flutter_native_contact_picker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.7" data-path="../chapter12/12.7适配flutter_timezone.html">
            
                <a href="../chapter12/12.7适配flutter_timezone.html">
            
                    
                    12.7适配flutter_timezone.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.8" data-path="../chapter12/12.8适配flutter_exit_app.html">
            
                <a href="../chapter12/12.8适配flutter_exit_app.html">
            
                    
                    12.8适配flutter_exit_app.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.9" data-path="../chapter12/12.9适配flutter_phone_direct_caller.html">
            
                <a href="../chapter12/12.9适配flutter_phone_direct_caller.html">
            
                    
                    12.9适配flutter_phone_direct_caller
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.10" data-path="../chapter12/12.10适配flutter_app_icon_badge.html">
            
                <a href="../chapter12/12.10适配flutter_app_icon_badge.html">
            
                    
                    12.10适配flutter_app_icon_badge
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.11" data-path="../chapter12/12.11适配memory_info.html">
            
                <a href="../chapter12/12.11适配memory_info.html">
            
                    
                    12.11适配memory_info
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" >
            
                <span>
            
                    
                    13.1DevTool使用
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" >
            
                <span>
            
                    
                    13.1DevTool使用
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" >
            
                <a target="_blank" href="https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/05_performance/performance-delimitation.md">
            
                    
                    13.2性能分析定界(OpenHarmony平台)指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" >
            
                <a target="_blank" href="https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/05_performance/performance-threads-sequence.md">
            
                    
                    13.3性能分析第一步-梳理线程顺序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" >
            
                <a target="_blank" href="https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/05_performance/performance-frame-rendering-tracking.md">
            
                    
                    13.4性能分析-帧渲染跟踪
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.5" >
            
                <a target="_blank" href="https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/05_performance/performance-sliding-response-time.md">
            
                    
                    13.5性能分析-滑动响应时延
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.6" data-path="../chapter12/12.6如何调试代码">
            
                <span>
            
                    
                    13.6如何调试代码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" >
            
                <span>
            
                    
                    14.迁移实战
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" >
            
                <span>
            
                    
                    坚果驾考
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="../chapter14/14.2使用url_launcher.html">
            
                <a href="../chapter14/14.2使用url_launcher.html">
            
                    
                    14.2使用url_launcher
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.3" data-path="../chapter14/14.3flutter开发鸿蒙PC应用.html">
            
                <a href="../chapter14/14.3flutter开发鸿蒙PC应用.html">
            
                    
                    14.3flutter开发鸿蒙PC应用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.15" >
            
                <span>
            
                    
                    15.上架审核
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" >
            
                <span>
            
                    
                    16.FAQ
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.16.1" >
            
                <a target="_blank" href="https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/08_FAQ/environment.md">
            
                    
                    16.1环境相关问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.2" data-path="../chapter16/16.3权限相关.html">
            
                <a href="../chapter16/16.3权限相关.html">
            
                    
                    16.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.3" >
            
                <a target="_blank" href="https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/08_FAQ/ohos_engine.md">
            
                    
                    ohos引擎产物编译相关问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.4" >
            
                <a target="_blank" href="https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/08_FAQ/ohos_hap.md">
            
                    
                    ohos应用编译相关问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.5" >
            
                <a target="_blank" href="https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/08_FAQ/ohos_code.md">
            
                    
                    ohos代码开发相关问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.6" >
            
                <a target="_blank" href="https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/08_FAQ/ohos_run.md">
            
                    
                    ohos运行相关问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.7" >
            
                <a target="_blank" href="https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/README.md">
            
                    
                    功能开发相关问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.8" >
            
                <a target="_blank" href="https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/08_FAQ/flutter_cppcrash_guideline.md">
            
                    
                    解析flutter相关的cppcrash堆栈
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.17" >
            
                <span>
            
                    
                    17.阅读更多
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" >
            
                <span>
            
                    
                    现有Flutter项目支持鸿蒙
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../chapter17/17.2平台判断与问题处理指南.html">
            
                <a href="../chapter17/17.2平台判断与问题处理指南.html">
            
                    
                    17.2平台判断与问题处理指南
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.18" >
            
                <span>
            
                    
                    18.关于未来
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.18.1" >
            
                <span>
            
                    
                    致谢
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>

</nav>
     
  </div>

  <!-- Content nav -->
  <div class="book-anchor">
    <div class="book-anchor-title"></div>

    <div class="book-anchor-body"></div>
  </div>

  <div class="book-body">
    
    <div class="body-inner">
       

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >8.4 混合渲染开发实践：以 fluttertpc_scan 三方库为例</a>
    </h1>
</div>



      <div class="page-wrapper" tabindex="-1" role="main">
        <div class="page-inner">
          
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
          <section class="normal markdown-section">
             
                <div id="vip-container">
                    <h2 id="&#x4E00;&#x3001;&#x80CC;&#x666F;&#x4E0E;&#x4EF7;&#x503C;"><a name="&#x4E00;&#x3001;&#x80CC;&#x666F;&#x4E0E;&#x4EF7;&#x503C;" class="plugin-anchor" href="#&#x4E00;&#x3001;&#x80CC;&#x666F;&#x4E0E;&#x4EF7;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E00;&#x3001;&#x80CC;&#x666F;&#x4E0E;&#x4EF7;&#x503C;</h2>
<p>&#x5728;&#x8DE8;&#x5E73;&#x53F0;&#x5F00;&#x53D1;&#x4E2D;&#xFF0C;Flutter &#x4EE5;&#x5176;&#x9AD8;&#x6548;&#x7684; UI &#x6784;&#x5EFA;&#x80FD;&#x529B;&#x8457;&#x79F0;&#xFF0C;&#x800C;&#x9E3F;&#x8499; Next&#xFF08;OpenHarmony&#xFF09;&#x5219;&#x63D0;&#x4F9B;&#x4E86;&#x6DF1;&#x5EA6;&#x7CFB;&#x7EDF;&#x96C6;&#x6210;&#x7684;&#x539F;&#x751F;&#x80FD;&#x529B;&#x3002;&#x5C06;&#x4E24;&#x8005;&#x7ED3;&#x5408;&#xFF0C;&#x53EF;&#x5B9E;&#x73B0; <strong>UI &#x8DE8;&#x5E73;&#x53F0; + &#x539F;&#x751F;&#x529F;&#x80FD;&#x6DF1;&#x5EA6;&#x878D;&#x5408;</strong> &#x7684;&#x6DF7;&#x5408;&#x6E32;&#x67D3;&#x6A21;&#x5F0F;&#x3002;&#x672C;&#x6587;&#x4EE5;&#x626B;&#x63CF;&#x5E93; <a href="https://gitcode.com/nutpi/fluttertpc_scan" target="_blank">fluttertpc_scan</a> &#x4E3A;&#x4F8B;&#xFF0C;&#x8BE6;&#x89E3;&#x6DF7;&#x5408;&#x5F00;&#x53D1;&#x7684;&#x6838;&#x5FC3;&#x6D41;&#x7A0B;&#x3002;</p>
<hr>
<h2 id="&#x4E8C;&#x3001;&#x73AF;&#x5883;&#x914D;&#x7F6E;&#xFF08;&#x5173;&#x952E;&#x7EC6;&#x8282;&#x4F18;&#x5316;&#xFF09;"><a name="&#x4E8C;&#x3001;&#x73AF;&#x5883;&#x914D;&#x7F6E;&#xFF08;&#x5173;&#x952E;&#x7EC6;&#x8282;&#x4F18;&#x5316;&#xFF09;" class="plugin-anchor" href="#&#x4E8C;&#x3001;&#x73AF;&#x5883;&#x914D;&#x7F6E;&#xFF08;&#x5173;&#x952E;&#x7EC6;&#x8282;&#x4F18;&#x5316;&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E8C;&#x3001;&#x73AF;&#x5883;&#x914D;&#x7F6E;&#xFF08;&#x5173;&#x952E;&#x7EC6;&#x8282;&#x4F18;&#x5316;&#xFF09;</h2>
<h3 id="1-&#x5DE5;&#x5177;&#x94FE;&#x7248;&#x672C;&#x8981;&#x6C42;"><a name="1-&#x5DE5;&#x5177;&#x94FE;&#x7248;&#x672C;&#x8981;&#x6C42;" class="plugin-anchor" href="#1-&#x5DE5;&#x5177;&#x94FE;&#x7248;&#x672C;&#x8981;&#x6C42;"><i class="fa fa-link" aria-hidden="true"></i></a>1. &#x5DE5;&#x5177;&#x94FE;&#x7248;&#x672C;&#x8981;&#x6C42;</h3>
<table>
<thead>
<tr>
<th>&#x5DE5;&#x5177;</th>
<th>&#x6700;&#x4F4E;&#x7248;&#x672C;</th>
<th>&#x5907;&#x6CE8;</th>
</tr>
</thead>
<tbody>
<tr>
<td>Flutter SDK</td>
<td>3.19.0+</td>
<td>&#x652F;&#x6301;ohos&#x7684;FlutterSDK</td>
</tr>
<tr>
<td>DevEco Studio</td>
<td>5.0.1 Release</td>
<td>&#x9700;&#x914D;&#x7F6E; OpenHarmony 5.0+ SDK</td>
</tr>
</tbody>
</table>
<h3 id="2-&#x73AF;&#x5883;&#x9A8C;&#x8BC1;"><a name="2-&#x73AF;&#x5883;&#x9A8C;&#x8BC1;" class="plugin-anchor" href="#2-&#x73AF;&#x5883;&#x9A8C;&#x8BC1;"><i class="fa fa-link" aria-hidden="true"></i></a>2. &#x73AF;&#x5883;&#x9A8C;&#x8BC1;</h3>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x9A8C;&#x8BC1; Flutter &#x73AF;&#x5883;</span>
flutter doctor -v

<span class="hljs-comment"># &#x786E;&#x8BA4;&#x9E3F;&#x8499; SDK &#x8DEF;&#x5F84;</span>
<span class="hljs-comment"># DevEco Studio &#x2192; File &#x2192; Settings &#x2192; SDK Manager &#x2192; OpenHarmony SDK</span>
</code></pre>
<hr>
<h2 id="&#x4E09;&#x3001;&#x6DF7;&#x5408;&#x6E32;&#x67D3;&#x5B9E;&#x73B0;&#xFF08;&#x4EE3;&#x7801;&#x6DF1;&#x5EA6;&#x4F18;&#x5316;&#xFF09;"><a name="&#x4E09;&#x3001;&#x6DF7;&#x5408;&#x6E32;&#x67D3;&#x5B9E;&#x73B0;&#xFF08;&#x4EE3;&#x7801;&#x6DF1;&#x5EA6;&#x4F18;&#x5316;&#xFF09;" class="plugin-anchor" href="#&#x4E09;&#x3001;&#x6DF7;&#x5408;&#x6E32;&#x67D3;&#x5B9E;&#x73B0;&#xFF08;&#x4EE3;&#x7801;&#x6DF1;&#x5EA6;&#x4F18;&#x5316;&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E09;&#x3001;&#x6DF7;&#x5408;&#x6E32;&#x67D3;&#x5B9E;&#x73B0;&#xFF08;&#x4EE3;&#x7801;&#x6DF1;&#x5EA6;&#x4F18;&#x5316;&#xFF09;</h2>
<h3 id="1-&#x9E3F;&#x8499;&#x539F;&#x751F;&#x6A21;&#x5757;&#x5F00;&#x53D1;"><a name="1-&#x9E3F;&#x8499;&#x539F;&#x751F;&#x6A21;&#x5757;&#x5F00;&#x53D1;" class="plugin-anchor" href="#1-&#x9E3F;&#x8499;&#x539F;&#x751F;&#x6A21;&#x5757;&#x5F00;&#x53D1;"><i class="fa fa-link" aria-hidden="true"></i></a>1. &#x9E3F;&#x8499;&#x539F;&#x751F;&#x6A21;&#x5757;&#x5F00;&#x53D1;</h3>
<h4 id="11-&#x4E8C;&#x7EF4;&#x7801;&#x626B;&#x63CF;&#x7EC4;&#x4EF6;&#x5C01;&#x88C5;"><a name="11-&#x4E8C;&#x7EF4;&#x7801;&#x626B;&#x63CF;&#x7EC4;&#x4EF6;&#x5C01;&#x88C5;" class="plugin-anchor" href="#11-&#x4E8C;&#x7EF4;&#x7801;&#x626B;&#x63CF;&#x7EC4;&#x4EF6;&#x5C01;&#x88C5;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1 &#x4E8C;&#x7EF4;&#x7801;&#x626B;&#x63CF;&#x7EC4;&#x4EF6;&#x5C01;&#x88C5;</h4>
<pre><code class="lang-typescript">@Component
<span class="hljs-keyword">export</span> struct CustomScanPage {
  @StorageLink(CameraConstants.CUSTOM_SCAN_PAGE_IS_BACKGROUND_NAME)
  @Watch(<span class="hljs-string">&apos;onBackgroundUpdate&apos;</span>) isBackground: <span class="hljs-built_in">boolean</span> = <span class="hljs-literal">false</span>;
  @State params: Map&lt;<span class="hljs-built_in">String</span>, <span class="hljs-built_in">Object</span>&gt; | <span class="hljs-literal">null</span> = <span class="hljs-literal">null</span>
  @State customScanVM: CustomScanViewModel = CustomScanViewModel.getInstance();
  <span class="hljs-keyword">private</span> mXComponentController: XComponentController = <span class="hljs-keyword">new</span> XComponentController();
  @State scanLineColor: <span class="hljs-built_in">string</span> = <span class="hljs-string">&quot;#ff4caf50&quot;</span>
  <span class="hljs-keyword">private</span> mScale: <span class="hljs-built_in">number</span> = <span class="hljs-number">1.0</span>
  @State animationOrdinate: <span class="hljs-built_in">number</span> = CameraConstants.SCAN_DIVIDER_OFFSET_BEGIN
  @State pauseScan: <span class="hljs-built_in">boolean</span> = <span class="hljs-literal">false</span>
  args?: Params
  build() {
    Column() {
      Stack() {
        XComponent({
          id: CameraConstants.CAMERA_COMPONENT_ID,
          <span class="hljs-keyword">type</span>: CameraConstants.CAMERA_COMPONENT_TYPE,
          controller: <span class="hljs-keyword">this</span>.mXComponentController
        })
          .onLoad(() =&gt; {
            Log.i(TAG, <span class="hljs-string">&apos;XComponent onLoad&apos;</span>)
            <span class="hljs-keyword">this</span>.customScanStart()
          })
          .width(<span class="hljs-keyword">this</span>.customScanVM.cameraCompWidth)
          .height(<span class="hljs-keyword">this</span>.customScanVM.cameraCompHeight)
          .position({
            x: CameraConstants.SCAN_COMPONENT_POSITION_X,
            y: CameraConstants.SCAN_COMPONENT_POSITION_Y
          })

        <span class="hljs-keyword">this</span>.ScanBorder()
      }
      .alignContent(Alignment.Center)
      .height(CameraConstants.SCAN_COMPONENT_WIDTH_100)
      .width(CameraConstants.SCAN_COMPONENT_WIDTH_100)
      .position({
        x: CameraConstants.SCAN_COMPONENT_POSITION_X,
        y: CameraConstants.SCAN_COMPONENT_POSITION_Y
      })
      .backgroundColor(Color.Grey)
    }
    .height(CameraConstants.SCAN_COMPONENT_WIDTH_100)
    .width(CameraConstants.SCAN_COMPONENT_WIDTH_100)
    .alignItems(HorizontalAlign.Center)
    .justifyContent(FlexAlign.Center)
    .backgroundColor(Color.White)
  }
  aboutToAppear(): <span class="hljs-built_in">void</span> {
    Log.i(TAG, <span class="hljs-string">&apos;aboutToAppear&apos;</span>)
    <span class="hljs-keyword">this</span>.initParams()
    <span class="hljs-comment">// &#x6CE8;&#x518C;XComp&#x5C3A;&#x5BF8;&#x4FEE;&#x6539;&#x56DE;&#x8C03;</span>
    <span class="hljs-keyword">this</span>.customScanVM.regXCompSizeUpdateListener((width: <span class="hljs-built_in">number</span>, height: <span class="hljs-built_in">number</span>) =&gt; {
      <span class="hljs-comment">// &#x52A8;&#x6001;&#x66F4;&#x65B0;XComponent&#x7684;Surface&#x5C3A;&#x5BF8;</span>
      <span class="hljs-keyword">this</span>.updateCameraSurfaceSize(width, height);
    })

    <span class="hljs-comment">// &#x6CE8;&#x518C;&#x626B;&#x63CF;&#x72B6;&#x6001;&#x76D1;&#x542C;&#x56DE;&#x8C03;</span>
    <span class="hljs-keyword">this</span>.customScanVM.regScanStatusUpdateListener((isPause: <span class="hljs-built_in">boolean</span>) =&gt; {
      <span class="hljs-comment">/*&#x6D4B;&#x8BD5;&#xFF0C;resume ispause=false&#x65F6;&#xFF0C;&#x5EF6;&#x65F6;&#x663E;&#x793A;&#x52A8;&#x753B;&#x6548;&#x679C;&#xFF0C;&#x68C0;&#x67E5;&#x662F;&#x5426;&#x9ED1;&#x5C4F;*/</span>
      <span class="hljs-keyword">if</span> (!isPause) {
        setTimeout(() =&gt; {
          <span class="hljs-keyword">this</span>.pauseScan = isPause;
        }, <span class="hljs-number">500</span>);
      } <span class="hljs-keyword">else</span> {
        <span class="hljs-keyword">this</span>.pauseScan = isPause;
      }
    })

  }
}
</code></pre>
<h4 id="12-&#x63D2;&#x4EF6;&#x7F16;&#x5199;"><a name="12-&#x63D2;&#x4EF6;&#x7F16;&#x5199;" class="plugin-anchor" href="#12-&#x63D2;&#x4EF6;&#x7F16;&#x5199;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2 &#x63D2;&#x4EF6;&#x7F16;&#x5199;</h4>
<pre><code class="lang-typescript"><span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> ScanPlugin <span class="hljs-keyword">implements</span> FlutterPlugin, MethodCallHandler, AbilityAware {
  <span class="hljs-keyword">private</span> channel: MethodChannel | <span class="hljs-literal">null</span> = <span class="hljs-literal">null</span>
  <span class="hljs-keyword">private</span> flutterPluginBinding: FlutterPluginBinding | <span class="hljs-literal">null</span> = <span class="hljs-literal">null</span>
  <span class="hljs-keyword">private</span> ability: UIAbility | <span class="hljs-literal">null</span> = <span class="hljs-literal">null</span>
  <span class="hljs-keyword">private</span> mainWindow: <span class="hljs-built_in">window</span>.Window | <span class="hljs-literal">null</span> = <span class="hljs-literal">null</span>;

  onAttachedToEngine(binding: FlutterPluginBinding): <span class="hljs-built_in">void</span> {
    Log.i(TAG, <span class="hljs-string">&apos;onAttachedToEngine&apos;</span>)
    <span class="hljs-keyword">this</span>.channel = <span class="hljs-keyword">new</span> MethodChannel(binding.getBinaryMessenger(), CHANNEL_NAME)
    <span class="hljs-keyword">this</span>.channel?.setMethodCallHandler(<span class="hljs-keyword">this</span>)
    <span class="hljs-keyword">this</span>.flutterPluginBinding = binding

    binding.getPlatformViewRegistry()
      .registerViewFactory(CHANNEL_VIEW_NAME, <span class="hljs-keyword">new</span> ScanViewFactory(binding.getBinaryMessenger()))

  }

  onDetachedFromEngine(binding: FlutterPluginBinding): <span class="hljs-built_in">void</span> {
    Log.i(TAG, <span class="hljs-string">&apos;onDetachedFromEngine&apos;</span>)
    <span class="hljs-keyword">this</span>.channel?.setMethodCallHandler(<span class="hljs-literal">null</span>)
    <span class="hljs-keyword">this</span>.channel = <span class="hljs-literal">null</span>

  }

  onDetachedFromAbility(): <span class="hljs-built_in">void</span> {
    <span class="hljs-keyword">this</span>.ability = <span class="hljs-literal">null</span>
    <span class="hljs-keyword">this</span>.offWindowEvent()
  }

  onAttachedToAbility(binding: AbilityPluginBinding): <span class="hljs-built_in">void</span> {
    <span class="hljs-keyword">this</span>.ability = binding.getAbility()
  }

  onWindowEvent(context: Context) {
    <span class="hljs-keyword">try</span> {
      <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.mainWindow == <span class="hljs-literal">null</span>) {
        <span class="hljs-keyword">this</span>.mainWindow = FlutterManager.getInstance()
          .getWindowStage(FlutterManager.getInstance().getUIAbility(context))
          .getMainWindowSync();
        <span class="hljs-keyword">this</span>.mainWindow?.on(<span class="hljs-string">&apos;windowEvent&apos;</span>, (data: <span class="hljs-built_in">window</span>.WindowEventType) =&gt; {
          <span class="hljs-keyword">if</span> (data === <span class="hljs-built_in">window</span>.WindowEventType.WINDOW_SHOWN) {
            AppStorage.setOrCreate(CameraConstants.CUSTOM_SCAN_PAGE_IS_BACKGROUND_NAME, <span class="hljs-literal">false</span>)
          } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (data === <span class="hljs-built_in">window</span>.WindowEventType.WINDOW_HIDDEN) {
            AppStorage.setOrCreate(CameraConstants.CUSTOM_SCAN_PAGE_IS_BACKGROUND_NAME, <span class="hljs-literal">true</span>)
          }
        });
      }
    } <span class="hljs-keyword">catch</span> (exception) {
      Log.e(TAG, <span class="hljs-string">&apos;Failed to register callback. Cause: &apos;</span> + <span class="hljs-built_in">JSON</span>.stringify(exception));
    }
  }

  offWindowEvent() {
    <span class="hljs-keyword">try</span> {
      <span class="hljs-keyword">this</span>.mainWindow?.off(<span class="hljs-string">&apos;windowEvent&apos;</span>);
    } <span class="hljs-keyword">catch</span> (exception) {
      Log.e(TAG, <span class="hljs-string">&apos;Failed to register callback. Cause: &apos;</span> + <span class="hljs-built_in">JSON</span>.stringify(exception));
    }
  }

  onMethodCall(call: MethodCall, result: MethodResult): <span class="hljs-built_in">void</span> {
    <span class="hljs-keyword">this</span>.onWindowEvent(<span class="hljs-keyword">this</span>.ability!.context)
    <span class="hljs-keyword">try</span> {
      <span class="hljs-keyword">switch</span> (call.method) {
        <span class="hljs-keyword">case</span> <span class="hljs-string">&quot;getPlatformVersion&quot;</span>:
          <span class="hljs-keyword">this</span>.getInfo(result)
          <span class="hljs-keyword">break</span>;
        <span class="hljs-keyword">case</span> <span class="hljs-string">&quot;parse&quot;</span>:
          <span class="hljs-keyword">this</span>.imgParse(call, result)
          <span class="hljs-keyword">break</span>;
        <span class="hljs-keyword">default</span>:
          result.notImplemented()
          <span class="hljs-keyword">break</span>;
      }
    } <span class="hljs-keyword">catch</span> (err) {
      Log.e(TAG, <span class="hljs-string">&apos;onMethodCall failed: &apos;</span> + err);
      result.error(<span class="hljs-string">&quot;BarcodeScanPlugin&quot;</span>, <span class="hljs-string">&quot;onMethodCall failed with err&quot;</span>, err);
    }

  }

  getUniqueClassName(): <span class="hljs-built_in">string</span> {
    Log.i(TAG, <span class="hljs-string">&apos;getUniqueClassName&apos;</span>)
    <span class="hljs-keyword">return</span> TAG

  }
}
</code></pre>
<p>&#x5176;&#x4E2D;&#x6700;&#x91CD;&#x8981;&#x7684;&#x5C31;&#x662F;&#x4E0B;&#x9762;&#x8FD9;&#x6BB5;&#xFF0C;&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#x7684;&#x4F5C;&#x7528;&#x662F;&#x5C06;&#x4E00;&#x4E2A;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x539F;&#x751F;&#x89C6;&#x56FE;&#x5DE5;&#x5382;&#xFF08;ScanViewFactory&#xFF09;&#x6CE8;&#x518C;&#x5230; Flutter &#x5F15;&#x64CE;&#x4E2D;&#x3002;&#x6CE8;&#x518C;&#x5B8C;&#x6210;&#x540E;&#xFF0C;Flutter &#x7AEF;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; CHANNEL_VIEW_NAME &#x6765;&#x8BF7;&#x6C42;&#x521B;&#x5EFA;&#x8FD9;&#x4E2A;&#x539F;&#x751F;&#x89C6;&#x56FE;&#x3002;&#x5177;&#x4F53;&#x6765;&#x8BF4;&#xFF0C;&#x5F53; Flutter &#x7AEF;&#x4F7F;&#x7528; AndroidView &#x6216; UiKitView&#xFF08;&#x5728; iOS &#x4E2D;&#xFF09;&#x65F6;&#xFF0C;Flutter &#x5F15;&#x64CE;&#x4F1A;&#x8C03;&#x7528;&#x6CE8;&#x518C;&#x7684; PlatformViewFactory &#x6765;&#x521B;&#x5EFA;&#x5BF9;&#x5E94;&#x7684;&#x539F;&#x751F;&#x89C6;&#x56FE;</p>
<pre><code class="lang-typescript">binding.getPlatformViewRegistry()
      .registerViewFactory(CHANNEL_VIEW_NAME, <span class="hljs-keyword">new</span> ScanViewFactory(binding.getBinaryMessenger()))
</code></pre>
<hr>
<h3 id="2-flutter-&#x7AEF;&#x96C6;&#x6210;&#xFF08;&#x589E;&#x5F3A;&#x5065;&#x58EE;&#x6027;&#xFF09;"><a name="2-flutter-&#x7AEF;&#x96C6;&#x6210;&#xFF08;&#x589E;&#x5F3A;&#x5065;&#x58EE;&#x6027;&#xFF09;" class="plugin-anchor" href="#2-flutter-&#x7AEF;&#x96C6;&#x6210;&#xFF08;&#x589E;&#x5F3A;&#x5065;&#x58EE;&#x6027;&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a>2. Flutter &#x7AEF;&#x96C6;&#x6210;&#xFF08;&#x589E;&#x5F3A;&#x5065;&#x58EE;&#x6027;&#xFF09;</h3>
<h4 id="21-&#x63D2;&#x4EF6;&#x63A5;&#x53E3;&#x5B9A;&#x4E49;"><a name="21-&#x63D2;&#x4EF6;&#x63A5;&#x53E3;&#x5B9A;&#x4E49;" class="plugin-anchor" href="#21-&#x63D2;&#x4EF6;&#x63A5;&#x53E3;&#x5B9A;&#x4E49;"><i class="fa fa-link" aria-hidden="true"></i></a>2.1 &#x63D2;&#x4EF6;&#x63A5;&#x53E3;&#x5B9A;&#x4E49;</h4>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Scan</span> </span>{
  <span class="hljs-keyword">static</span> <span class="hljs-keyword">const</span> MethodChannel _channel = <span class="hljs-keyword">const</span> MethodChannel(<span class="hljs-string">&apos;chavesgu/scan&apos;</span>);

  <span class="hljs-keyword">static</span> Future&lt;<span class="hljs-built_in">String</span>&gt; <span class="hljs-keyword">get</span> platformVersion <span class="hljs-keyword">async</span> {
    <span class="hljs-keyword">final</span> <span class="hljs-built_in">String</span> version = <span class="hljs-keyword">await</span> _channel.invokeMethod(<span class="hljs-string">&apos;getPlatformVersion&apos;</span>);
    <span class="hljs-keyword">return</span> version;
  }

  <span class="hljs-keyword">static</span> Future&lt;<span class="hljs-built_in">String</span>?&gt; parse(<span class="hljs-built_in">String</span> path) <span class="hljs-keyword">async</span> {
    <span class="hljs-keyword">final</span> <span class="hljs-built_in">String</span>? result = <span class="hljs-keyword">await</span> _channel.invokeMethod(<span class="hljs-string">&apos;parse&apos;</span>, path);
    <span class="hljs-keyword">return</span> result;
  }
}
  <span class="hljs-keyword">void</span> _onPlatformViewCreated(<span class="hljs-built_in">int</span> id) {
    _channel = MethodChannel(<span class="hljs-string">&apos;chavesgu/scan/method_$id&apos;</span>);
    _channel?.setMethodCallHandler((MethodCall call) <span class="hljs-keyword">async</span> {
      <span class="hljs-keyword">if</span> (call.method == <span class="hljs-string">&apos;onCaptured&apos;</span>) {
        <span class="hljs-keyword">if</span> (widget.onCapture != <span class="hljs-keyword">null</span>)
          widget.onCapture!(call.arguments.toString());
      }
    });
    widget.controller?._channel = _channel;
  }
</code></pre>
<h4 id="22-&#x6DF7;&#x5408;&#x6E32;&#x67D3;&#x9875;&#x9762;"><a name="22-&#x6DF7;&#x5408;&#x6E32;&#x67D3;&#x9875;&#x9762;" class="plugin-anchor" href="#22-&#x6DF7;&#x5408;&#x6E32;&#x67D3;&#x9875;&#x9762;"><i class="fa fa-link" aria-hidden="true"></i></a>2.2 &#x6DF7;&#x5408;&#x6E32;&#x67D3;&#x9875;&#x9762;</h4>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">_ScanViewState</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">State</span>&lt;<span class="hljs-title">ScanView</span>&gt; </span>{
  MethodChannel? _channel;

  <span class="hljs-meta">@override</span>
  Widget build(BuildContext context) {
    <span class="hljs-keyword">if</span> (defaultTargetPlatform == TargetPlatform.iOS) {
      <span class="hljs-keyword">return</span> UiKitView(
        viewType: <span class="hljs-string">&apos;chavesgu/scan_view&apos;</span>,
        creationParamsCodec: StandardMessageCodec(),
        creationParams: {
          <span class="hljs-string">&quot;r&quot;</span>: widget.scanLineColor.red,
          <span class="hljs-string">&quot;g&quot;</span>: widget.scanLineColor.green,
          <span class="hljs-string">&quot;b&quot;</span>: widget.scanLineColor.blue,
          <span class="hljs-string">&quot;a&quot;</span>: widget.scanLineColor.opacity,
          <span class="hljs-string">&quot;scale&quot;</span>: widget.scanAreaScale,
        },
        onPlatformViewCreated: (id) {
          _onPlatformViewCreated(id);
        },
      );
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (defaultTargetPlatform == TargetPlatform.android) {
      <span class="hljs-keyword">return</span> AndroidView(
        viewType: <span class="hljs-string">&apos;chavesgu/scan_view&apos;</span>,
        creationParamsCodec: StandardMessageCodec(),
        creationParams: {
          <span class="hljs-string">&quot;r&quot;</span>: widget.scanLineColor.red,
          <span class="hljs-string">&quot;g&quot;</span>: widget.scanLineColor.green,
          <span class="hljs-string">&quot;b&quot;</span>: widget.scanLineColor.blue,
          <span class="hljs-string">&quot;a&quot;</span>: widget.scanLineColor.opacity,
          <span class="hljs-string">&quot;scale&quot;</span>: widget.scanAreaScale,
        },
        onPlatformViewCreated: (id) {
          _onPlatformViewCreated(id);
        },
      );
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (defaultTargetPlatform == TargetPlatform.ohos) {
      <span class="hljs-keyword">return</span> OhosView(
        viewType: <span class="hljs-string">&apos;chavesgu/scan_view&apos;</span>,
        creationParamsCodec: StandardMessageCodec(),
        creationParams: {
          <span class="hljs-string">&quot;r&quot;</span>: widget.scanLineColor.red,
          <span class="hljs-string">&quot;g&quot;</span>: widget.scanLineColor.green,
          <span class="hljs-string">&quot;b&quot;</span>: widget.scanLineColor.blue,
          <span class="hljs-string">&quot;a&quot;</span>: widget.scanLineColor.opacity,
          <span class="hljs-string">&quot;scale&quot;</span>: widget.scanAreaScale,
        },
        onPlatformViewCreated: (id) {
          _onPlatformViewCreated(id);
        },
      );
    } <span class="hljs-keyword">else</span> {
      <span class="hljs-keyword">return</span> Text(<span class="hljs-string">&apos;&#x5E73;&#x53F0;&#x6682;&#x4E0D;&#x652F;&#x6301;&apos;</span>);
    }
  }
}
</code></pre>
<hr>
<p>&#x4EE5;&#x4E0A;&#x4EE3;&#x7801;&#x6839;&#x636E;&#x4E0D;&#x540C;&#x7684;&#x76EE;&#x6807;&#x5E73;&#x53F0;&#xFF08;iOS&#x3001;Android &#x6216; OpenHarmony&#xFF09;&#x521B;&#x5EFA;&#x5BF9;&#x5E94;&#x7684;&#x539F;&#x751F;&#x89C6;&#x56FE;&#x3002;&#x5B83;&#x901A;&#x8FC7; PlatformView&#xFF08;&#x5982; UiKitView&#x3001;AndroidView &#x548C; OhosView&#xFF09;&#x6765;&#x5D4C;&#x5165;&#x539F;&#x751F;&#x4EE3;&#x7801;&#x5B9E;&#x73B0;&#x7684;&#x529F;&#x80FD;&#xFF08;&#x5982;&#x4E8C;&#x7EF4;&#x7801;&#x626B;&#x63CF;&#xFF09;</p>
<h2 id="&#x56DB;&#x3001;&#x5173;&#x952E;&#x6280;&#x672F;&#x70B9;&#x8BB2;&#x89E3;"><a name="&#x56DB;&#x3001;&#x5173;&#x952E;&#x6280;&#x672F;&#x70B9;&#x8BB2;&#x89E3;" class="plugin-anchor" href="#&#x56DB;&#x3001;&#x5173;&#x952E;&#x6280;&#x672F;&#x70B9;&#x8BB2;&#x89E3;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x56DB;&#x3001;&#x5173;&#x952E;&#x6280;&#x672F;&#x70B9;&#x8BB2;&#x89E3;</h2>
<h3 id="1-flutter&#x4E0E;harmonyosnext&#x901A;&#x4FE1;"><a name="1-flutter&#x4E0E;harmonyosnext&#x901A;&#x4FE1;" class="plugin-anchor" href="#1-flutter&#x4E0E;harmonyosnext&#x901A;&#x4FE1;"><i class="fa fa-link" aria-hidden="true"></i></a>1. Flutter&#x4E0E;HarmonyOSNEXT&#x901A;&#x4FE1;</h3>
<p>&#x5728;&#x4E0A;&#x8FF0;&#x4EE3;&#x7801;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x901A;&#x8FC7;creationParams&#x4F20;&#x9012;&#x4E86;&#x90E8;&#x5206;&#x6570;&#x636E;&#x7ED9;&#x539F;&#x751F;&#x9E3F;&#x8499;&#x7684;view&#xFF0C;&#x90A3;&#x4ED6;&#x5982;&#x4F55;&#x63A5;&#x6536;&#x5462;&#xFF0C;&#x8FD9;&#x5C31;&#x9700;&#x8981;&#x5728;&#x9E3F;&#x8499;&#x7AEF;&#x505A;&#x5904;&#x7406;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x7EE7;&#x627F;FlutterPlugin&#x7684;&#x7C7B;ScanPlugin&#x4E2D;&#x6CE8;&#x518C;&#x4E86;&#x4E00;&#x4E2A;&#x5DE5;&#x5382;&#x7C7B;ScanViewFactory&#xFF0C;&#x5F53;&#x6709;&#x6570;&#x636E;&#x8FC7;&#x6765;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F1A;&#x901A;&#x8FC7;binding.getBinaryMessenger()&#x4F20;&#x9012;&#x5230;&#x8FD9;&#x4E2A;&#x7C7B;&#x4E2D;</p>
<pre><code class="lang-typescript">
<span class="hljs-keyword">import</span> {
  BinaryMessenger,
  PlatformView,
  Log,
  PlatformViewFactory,
  StandardMessageCodec
} from <span class="hljs-string">&apos;@ohos/flutter_ohos&apos;</span>;
<span class="hljs-keyword">import</span> { ScanPlatformView } from <span class="hljs-string">&apos;../views/ScanPlatformView&apos;</span>;

<span class="hljs-keyword">const</span> TAG: <span class="hljs-built_in">string</span> = <span class="hljs-string">&quot;FlutterScanPlugin&quot;</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> ScanViewFactory extends PlatformViewFactory {
  <span class="hljs-keyword">private</span> messenger: BinaryMessenger;

  <span class="hljs-keyword">constructor</span>(messenger: BinaryMessenger) {
    <span class="hljs-keyword">super</span>(StandardMessageCodec.INSTANCE);
    <span class="hljs-keyword">this</span>.messenger = messenger;
  }

  <span class="hljs-keyword">public</span> create(context: Context, id: <span class="hljs-built_in">number</span>, args: <span class="hljs-built_in">Object</span>): PlatformView {
    Log.i(TAG, <span class="hljs-string">&apos;create&apos;</span>)
    <span class="hljs-keyword">let</span> params: Map&lt;<span class="hljs-built_in">String</span>, <span class="hljs-built_in">Object</span>&gt; = args as Map&lt;<span class="hljs-built_in">String</span>, <span class="hljs-built_in">Object</span>&gt;
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> ScanPlatformView(context, <span class="hljs-keyword">this</span>.messenger, id, params);
  }
}
</code></pre>
<p>&#x5728;create&#x51FD;&#x6570;&#x4E2D;&#x83B7;&#x53D6;&#x5230;&#x4E86;&#x4E00;&#x4E2A;HashMap&#xFF0C;&#x8FD9;&#x4E2A;MAP&#x91CC;&#x5C31;&#x662F;&#x6211;&#x4EEC;&#x5C06;&#x8981;&#x83B7;&#x53D6;&#x5230;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x5728;ScanPlatformView&#x7C7B;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x4E2D;&#x6211;&#x4EEC;&#x5C06;params&#x62FF;&#x51FA;&#x6765;&#xFF0C;getView&#x4F1A;&#x5C06;&#x4FE1;&#x606F;&#x4F20;&#x9012;&#x7ED9;&#x6700;&#x7EC8;&#x8981;&#x5C55;&#x793A;&#x626B;&#x7801;&#x754C;&#x9762;&#x7684;&#x9E3F;&#x8499;UI&#x9875;&#x9762;</p>
<pre><code class="lang-typescript">
@Observed
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> ScanPlatformView extends PlatformView <span class="hljs-keyword">implements</span> MethodCallHandler, QRCodeReadListener {
<span class="hljs-comment">///&#x7701;&#x7565;&#x90E8;&#x5206;&#x4EE3;&#x7801;...</span>
  <span class="hljs-keyword">public</span> getView(): WrappedBuilder&lt;[Params]&gt; {
    <span class="hljs-comment">// &#x8FD4;&#x56DE; WrappedBuilder&lt;[Params]&gt;&#xFF0C;&#x4E25;&#x683C;&#x5339;&#x914D;&#x57FA;&#x7C7B;&#x8981;&#x6C42;</span>
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> WrappedBuilder(CustomScanPage({ args: params }));
  }
<span class="hljs-comment">///&#x7701;&#x7565;&#x90E8;&#x5206;&#x4EE3;&#x7801;...</span>
}

@Component
<span class="hljs-keyword">export</span> struct CustomScanPage {
<span class="hljs-comment">///&#x7701;&#x7565;&#x90E8;&#x5206;&#x4EE3;&#x7801;...</span>
   aboutToAppear(): <span class="hljs-built_in">void</span> {
    <span class="hljs-keyword">if</span>(<span class="hljs-keyword">this</span>.args!=<span class="hljs-literal">null</span>){
      <span class="hljs-keyword">const</span> scanPlatformView = <span class="hljs-keyword">this</span>.args.platformView as ScanPlatformView;
      <span class="hljs-keyword">this</span>.params = scanPlatformView.params!;
    }
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.params) {
      <span class="hljs-keyword">this</span>.mScale = <span class="hljs-keyword">this</span>.params.get(<span class="hljs-string">&quot;scale&quot;</span>) as <span class="hljs-built_in">number</span>
      <span class="hljs-keyword">this</span>.customScanVM.setScale(<span class="hljs-keyword">this</span>.mScale)
      Log.i(TAG, <span class="hljs-string">&apos;initParams mScale=&apos;</span> + <span class="hljs-keyword">this</span>.mScale)
     <span class="hljs-keyword">let</span> r: <span class="hljs-built_in">number</span> = <span class="hljs-keyword">this</span>.params.get(<span class="hljs-string">&quot;r&quot;</span>) as <span class="hljs-built_in">number</span>
      <span class="hljs-keyword">let</span> g: <span class="hljs-built_in">number</span> = <span class="hljs-keyword">this</span>.params.get(<span class="hljs-string">&quot;g&quot;</span>) as <span class="hljs-built_in">number</span>
      <span class="hljs-keyword">let</span> b: <span class="hljs-built_in">number</span> = <span class="hljs-keyword">this</span>.params.get(<span class="hljs-string">&quot;b&quot;</span>) as <span class="hljs-built_in">number</span>
      <span class="hljs-keyword">let</span> a: <span class="hljs-built_in">number</span> = <span class="hljs-keyword">this</span>.params.get(<span class="hljs-string">&quot;a&quot;</span>) as <span class="hljs-built_in">number</span>
      a = <span class="hljs-built_in">Math</span>.max(<span class="hljs-number">0</span>, <span class="hljs-built_in">Math</span>.min(<span class="hljs-number">255</span>, a));
      r = <span class="hljs-built_in">Math</span>.max(<span class="hljs-number">0</span>, <span class="hljs-built_in">Math</span>.min(<span class="hljs-number">255</span>, r));
      g = <span class="hljs-built_in">Math</span>.max(<span class="hljs-number">0</span>, <span class="hljs-built_in">Math</span>.min(<span class="hljs-number">255</span>, g));
      b = <span class="hljs-built_in">Math</span>.max(<span class="hljs-number">0</span>, <span class="hljs-built_in">Math</span>.min(<span class="hljs-number">255</span>, b));

      <span class="hljs-comment">// const alpha = Math.max(0, Math.min(255, Math.floor(a * 256.0)));</span>
      <span class="hljs-comment">// &#x5C06; alpha &#x4ECE; 0-255 &#x8F6C;&#x6362;&#x4E3A; 0-1 &#x7684;&#x6D6E;&#x70B9;&#x6570;</span>
      <span class="hljs-comment">// const result = a / 255;</span>
      <span class="hljs-comment">// const alpha = Math.round(result * 100) / 100</span>
      Log.i(TAG, <span class="hljs-string">&apos;initParams scanLineColor a =&apos;</span> + a)
      <span class="hljs-keyword">this</span>.scanLineColor = <span class="hljs-keyword">this</span>.rgbaToHex(a, r, g, b)
  }
<span class="hljs-comment">///&#x7701;&#x7565;&#x90E8;&#x5206;&#x4EE3;&#x7801;...</span>
}
</code></pre>
<h3 id="2-flutter-&#x7AEF;&#x4F7F;&#x7528;"><a name="2-flutter-&#x7AEF;&#x4F7F;&#x7528;" class="plugin-anchor" href="#2-flutter-&#x7AEF;&#x4F7F;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a>2. Flutter &#x7AEF;&#x4F7F;&#x7528;</h3>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ScanPage</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">StatelessWidget</span> </span>{
  ScanController controller = ScanController();
  <span class="hljs-meta">@override</span>
  Widget build(BuildContext context) {
    <span class="hljs-keyword">return</span> Scaffold(
      body: SafeArea(
        top: <span class="hljs-keyword">true</span>,
        bottom: <span class="hljs-keyword">true</span>,
        child: Stack(
          children: [
            ScanView(
              controller: controller,
              scanAreaScale: <span class="hljs-number">.7</span>,
              scanLineColor: Colors.red,
              onCapture: (data) {
                Navigator.push(context, MaterialPageRoute(
                  builder: (BuildContext context) {
                    <span class="hljs-keyword">return</span> Scaffold(
                      appBar: AppBar(
                        title: Text(<span class="hljs-string">&apos;scan result&apos;</span>),
                      ),
                      body: Center(
                        child: Text(data),
                      ),
                    );
                  },
                )).then((value) {
                  controller.resume();
                });
              },
            ),
            Positioned(
              bottom: <span class="hljs-number">0</span>,
              child: Row(
                children: [
                  ElevatedButton(
                    child: Text(<span class="hljs-string">&quot;toggleTorchMode&quot;</span>),
                    onPressed: () {
                      controller.toggleTorchMode();
                    },
                  ),
                  ElevatedButton(
                    child: Text(<span class="hljs-string">&quot;pause&quot;</span>),
                    onPressed: () {
                      controller.pause();
                    },
                  ),
                  ElevatedButton(
                    child: Text(<span class="hljs-string">&quot;resume&quot;</span>),
                    onPressed: () {
                      controller.resume();
                    },
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
</code></pre>
<p>&#x901A;&#x8FC7;&#x672C;&#x6587;&#x7684;&#x63A5;&#x6536;&#xFF0C;&#x76F8;&#x4FE1;&#x5F00;&#x53D1;&#x8005;&#x53EF;&#x5FEB;&#x901F;&#x5B9E;&#x73B0; Flutter &#x4E0E;&#x9E3F;&#x8499; Next &#x7684;&#x6DF1;&#x5EA6;&#x96C6;&#x6210;&#xFF0C;&#x5728;&#x4FDD;&#x8BC1;&#x8DE8;&#x5E73;&#x53F0; UI &#x4E00;&#x81F4;&#x6027;&#x7684;&#x540C;&#x65F6;&#xFF0C;&#x5145;&#x5206;&#x53D1;&#x6325;&#x9E3F;&#x8499;&#x539F;&#x751F;&#x80FD;&#x529B;&#x3002;
&#x58F0;&#x660E;&#xFF1A;&#x56E0;&#x539F;&#x59CB;&#x4ED3;&#x5E93;&#x6709;BUG&#xFF0C;&#x65E0;&#x6CD5;&#x63D0;&#x4EA4;PR&#xFF0C;&#x6545;&#x6211;&#x624D;&#x91CD;&#x65B0;&#x4E0A;&#x4F20;&#x4E86;&#x4E00;&#x4EFD;&#xFF01;<a href="https://gitcode.com/openharmony-sig/fluttertpc_scan" target="_blank">https://gitcode.com/openharmony-sig/fluttertpc_scan</a> </p>
<footer class="page-footer"><span class="copyright">powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2025-05-15 21:45:17
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                </div>
                <script src="https://my.openwrite.cn/js/readmore.js"></script>
                <script>
                    var enablePlugin = false;
                    var allowDomain = "localhost";
                    if(allowDomain){
                        var currentDomain = location.hostname;
                        if ($.isArray(allowDomain)) {
                            $.each(allowDomain, function(index, item) {
                                if (currentDomain == item) {
                                    enablePlugin = true;
                                    return false;
                                }
                            });
                        }else{
                           if (currentDomain == allowDomain) {
                                enablePlugin = true;
                            }
                        }
                    }else{
                        enablePlugin = true;
                    }
                    
                    if(enablePlugin){
                        var isMobile = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
                        if (!isMobile) {
                            var btw = new BTWPlugin();
                            btw.init({"allowDomain":"localhost","blogId":"27976-1678928361372-483","name":"坚果派","qrcode":"https://luckly007.oss-cn-beijing.aliyuncs.com/images/image-20230316085818226.png","keyword":"鸿蒙坚果","id":"vip-container"});
                        }
                    }
                </script> 
          </section>
          
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>
 
          <div class="book-footer">
            
            <div class="donate">
              <div></div>
              <button class="donate-btn" onclick="showModal()">赞赏</button>
            </div>
             
            <div class="copyright"></div>
            
          </div>
          
        </div>
      </div>
      
    </div>

     
    <a
      href="8.1如何使用Flutter与鸿蒙通信 FlutterChannel.html"
      class="
        navigation navigation-prev
        navigation-unique
      "
      aria-label="Previous page: 8.1如何使用Flutter与鸿蒙通信 FlutterChannel"
    >
      <i class="fa fa-angle-left"></i>
    </a>
       
  </div>
  <script>
    function showModal() {
      document.getElementsByClassName("mask")[0].style.display = "block";
      document.getElementsByClassName("donate-modal")[0].style.display =
        "block";
    }
    // 切换赞赏码
    function showDonateImg(num) {
      let alipay = "";
      let wxpay = ""
      if(num){
        wxpay = "hidden"
      }else{
        alipay = "hidden"
      }
      document.getElementById("wxpay-code").hidden = wxpay;
      document.getElementById("alipay-code").hidden = alipay;
      document.getElementsByName("pay-way")[num].checked = "checked";
    }

    // 关闭赞赏框
    function closeDonateModal() {
      document.getElementsByClassName("mask")[0].style.display = "none";
      document.getElementsByClassName("donate-modal")[0].style.display = "none";
    }

    var gitbook = gitbook || [];
    gitbook.push(function () {
      gitbook.page.hasChanged({"page":{"title":"8.4 混合渲染开发实践：以 fluttertpc_scan 三方库为例","level":"1.8.2","depth":2,"next":{"title":"9.与原生混合渲染","level":"1.9","depth":1,"ref":"","articles":[{"title":"9.1Flutter OHOS外接纹理适配简介.md","level":"1.9.1","depth":2,"url":"https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/Flutter OHOS外接纹理适配简介.md","ref":"https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/Flutter OHOS外接纹理适配简介.md","articles":[]},{"title":"9.2如何使用多引擎 FlutterEngineGroup","level":"1.9.2","depth":2,"url":"https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/如何使用多引擎 FlutterEngineGroup.md","ref":"https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/如何使用多引擎 FlutterEngineGroup.md","articles":[]},{"title":"9.3如何使用PlatformView","level":"1.9.3","depth":2,"url":"https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/如何使用PlatformView.md","ref":"https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/如何使用PlatformView.md","articles":[]},{"title":"9.4PlatformView同层渲染方案适配切换指导","level":"1.9.4","depth":2,"url":"https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/PlatformView同层渲染方案适配切换指导.md","ref":"https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/PlatformView同层渲染方案适配切换指导.md","articles":[]},{"title":"9.5如何使用混合开发 module","level":"1.9.5","depth":2,"ref":"","articles":[]}]},"previous":{"title":"8.1如何使用Flutter与鸿蒙通信 FlutterChannel","level":"1.8.1","depth":2,"path":"chapter8/8.1如何使用Flutter与鸿蒙通信 FlutterChannel.md","ref":"./chapter8/8.1如何使用Flutter与鸿蒙通信 FlutterChannel.md","articles":[]},"dir":"ltr"},"config":{"plugins":["github-buttons@2.1.0","edit-link","splitter","tbfed-pagefooter","expandable-chapters","chapter-fold","back-to-top-button","code","pageview-count","popup","search-plus","-lunr","-search","splitter","-sharing","sharing-plus","theme-lou","mind-maps","emphasize","anchors","changyan","readmore","livereload","ace","livereload"],"root":".","styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"pluginsConfig":{"expandable-chapters":{}},"emphasize":{},"ace":{},"livereload":{},"splitter":{},"readmore":{"allowDomain":"localhost","blogId":"27976-1678928361372-483","name":"坚果派","qrcode":"https://luckly007.oss-cn-beijing.aliyuncs.com/images/image-20230316085818226.png","keyword":"鸿蒙坚果"},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"popup":{},"code":{"copyButtons":true},"theme-lou":{"hide-elements":[".summary .gitbook-link",".summary .divider"],"color":"#FF4848","book-anchor-title":"本章目录","copyright":{"author":"vx:nut_pie"},"forbidCopy":true,"logo":"assets/avatar.png","book-summary-title":"文章目录","search-placeholder":"输入关键字搜索","copyrightLogo":"assets/copyright.png","favicon":"assets/avatar.png","appleTouchIconPrecomposed152":"assets/avatar.png"},"changyan":{"appid":"cyvHoCPAs","conf":"0440cfc4168ba95d73cfc52dd4d5c60b"},"fontsettings":{"theme":"white","family":"sans","size":2},"mind-maps":{},"highlight":{},"back-to-top-button":{},"pageview-count":{},"github-buttons":{"repo":"ITmxs/gitbook","types":["star","watch","fork"],"size":"small"},"sharing":{"qq":false,"all":["qq","qzone","whatsapp","douban","facebook","google","instapaper","linkedin","messenger","twitter","weibo"],"douban":false,"facebook":false,"weibo":false,"twitter":false,"pocket":false,"google":false,"qzone":false},"edit-link":{"label":"编辑此页","base":"https://github.com/ITmxs/gitbook/edit/master/"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"坚果派","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"themeLou":{"nav":[{"target":"_blank","url":"https://www.gitbook.com/","name":"坚果派官网"},{"target":"_blank","url":"https://www.npmjs.com/package/package","name":"ArkUI实战"},{"target":"_blank","url":"https://space.bilibili.com/480883651","name":"元服务开发实践"},{"target":"_blank","url":"https://blog.51cto.com/jianguo","name":"OpenHarmony应用开发"}],"footer":{"donate":{"wechat":"https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202901895.png","message":"随意打赏，但不要超过一顿早餐钱 💕","wxpay":"https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202901895.png","alipay":"https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202843746.png","nickname":"breeze","button":"打赏","wechatText":"微信","alipayText":"支付宝","title":"『赠人玫瑰 🌹 手有余香 』","avatar":"http://xkapp-uat.oss-cn-hangzhou.aliyuncs.com/2e7a3f70-80ab-4b50-93ec-a04dfeef949b/avatar-100.png"},"copyright":true}}},"title":"Flutter for Harmony教程","language":"zh-hans","gitbook":"*","description":"Flutter for Harmony电子书教程"},"file":{"path":"chapter8/8.4 混合渲染开发实践：以 fluttertpc_scan 三方库为例.md","mtime":"2025-05-15T13:45:17.834Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2025-05-22T05:24:30.737Z"},"basePath":"..","book":{"language":""}});
    });
  </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-mind-maps/mindmaps.dist.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-changyan/changyan.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-ace/ace/ace.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-ace/ace.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-lou/lou.js"></script>
        
    

    </body>
</html>

